package com.meida.module.system.provider.service.impl;

import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.model.ListModel;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.common.utils.FlymeUtils;
import com.meida.module.system.client.entity.SysKeyword;
import com.meida.module.system.provider.mapper.SysKeywordMapper;
import com.meida.module.system.provider.service.SysKeywordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 关键词 实现类
 *
 * @author flyme
 * @date 2019-07-06
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SysKeywordServiceImpl extends BaseServiceImpl<SysKeywordMapper, SysKeyword> implements SysKeywordService {
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public ResultBody listEntityMap(ListModel listModel) {
        CriteriaQuery<EntityMap> cq = new CriteriaQuery(listModel, entityClass);
        cq.select(entityClass, "*");
        SysKeyword keyword = cq.getEntity(entityClass);
        if (FlymeUtils.isNotEmpty(keyword)) {
            cq.eq("kewordType", keyword.getKewordType());
        }
        return baseList(cq);
    }
}
